package com.party.core.service.count.impl;

import com.google.common.base.Strings;
import com.party.core.model.activity.Activity;
import com.party.core.service.activity.IActivityService;
import com.party.core.service.article.IArticleService;
import com.party.core.service.count.IModuleCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * Created by wei.li.
 *
 * @date 2017/12/22 0022
 * @time 11:24
 */

@Service
@Component(value = "activityCountService")
public class ActivityCountService implements IModuleCountService {

    @Autowired
    private IActivityService activityService;

    /**
     * 增加活动浏览量
     * @param id 业务编号
     */
    @Override
    public void addViewNum(String id) {
        if (!Strings.isNullOrEmpty(id)){
            Activity activity = activityService.get(id);
            if (null != activity){
                activity.setReadNum(activity.getReadNum() + 1);
                activityService.update(activity);
            }
        }
    }
}
